''''''''''''''''''''''''''''''''''''''''''''''''
' Enventory
'
' vbscript toolset to support administration, Enventory and control of AD Users and PC assets
'
' Copyright (C) ' by ufe@gmx.de
' started  July/August 2008, 
' based on work done within ::
'''''''''''''''''''''''''''''''''''
' Open Audit                  '
' http://open-audit.org	      '
' Software and Hardware Enventory '
' Outputs into MySQL          '
' (c) Mark Unwin 2003         '
'''''''''''''''''''''''''''''''''''
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.

' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License along
' with this program; if not, write to the Free Software Foundation, Inc.,
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
'
Option Explicit
'  64bit workaround
'
' this script code relies on 32bit COM objects, if we are running on
' a 64bit system we will want to run under WOW64 (the x86 emulator).

'http://blogs.msdn.com/b/joshpoley/archive/2008/09/18/running-32bit-dependent-scripts-in-a-64bit-world.aspx

dim myHostShell

public function IS64()
	On Error Resume Next
	
	Dim WshShell
	Dim OsType

	Set WshShell = CreateObject("WScript.Shell")

	OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

	If OsType = "x86" then
		'wscript.excho "Windows 32bit system detected"
		IS64 = false
	elseif OsType = "AMD64" then
		'wscript.echo "Windows 64bit system detected"
		IS64 = true
	end if
end function

public function ISshell64()
	'On Error Resume Next
	
	Dim host
	host = WScript.FullName
	host = lcase(host)
	'wscript.echo "ISshell64 host:" & host
	if is64() then
	'	wscript.echo "is 64"
	'	wscript.echo InStr(1, host, "system32", vbTextCompare)
		if InStr(1, host, "system32", vbTextCompare) <> 0 then
	'		wscript.echo "64 bit - 64bit shell detected"
			ISshell64 = true
		else
	'	wscript.echo InStr(1, host, "syswow64", vbTextCompare) 
		if  InStr(1, host, "syswow64", vbTextCompare) <> 0 then 
	'			wscript.echo "64 bit - 32bit shell detected"
				ISshell64 = false
			end if
		end if
	else
	   ISshell64 = false
	end if
end function

public function WinDirGet()
	dim shell
	set shell = WScript.CreateObject("WScript.Shell")
	WinDirGet = shell.ExpandEnvironmentStrings("%windir%")
end function

public function ParameterGet()
	dim strArg
	Dim ArgObj
	Set ArgObj = WScript.Arguments
	'wScript.Echo WScript.Arguments.Count
	ParameterGet = ""
	For Each strArg in ArgObj
		ParameterGet = ParameterGet & " " & strArg
    next
end function  
	

' check to see if we are on an AMD64 processor and running the
' wrong version of the scripting host.

if IS64() then
	myHostShell = "64"
else
	myHostShell =  "32"
end if

if ISshell64() then
	myHostShell = myHostShell & "/shell64"
else
	myHostShell = myHostShell & "/shell32"
end if 
 
 
if ISshell64() then
    dim newcmd
	newcmd = windirget()&"\SysWoW64\cscript.exe " & WScript.ScriptFullName & ParameterGet()
	dim shell
	dim exec
	dim ret
	set shell = WScript.CreateObject("WScript.Shell")
   'WScript.Echo(myHostShell & " start")
	'wscript.echo newcmd
    ret = Shell.Run (newcmd, 0, true)
	'WScript.Echo(myHostShell & " end")
	
    WScript.Quit(ret)
 end if
' the real script code goes here ...

'wscript.Echo(myHostShell & " go")

Public SuiteName : SuiteName = "E-nventory"
Public  SuiteProg : SuiteProg = "Hardware"

Dim EnventoryLogDir
Dim EnventoryDataDir
Dim EmailFrom
Dim EmailTo
Dim DDEEVV
Dim DBhistoryDays
Dim DBhistoryUnique
Dim DBTablePerComputer
Dim DBTablePerOU
Dim DBTableVersion : DBTableVersion = "0.6"
Dim RUNFrequence

Dim WSHFileSignature

Dim EmailCc
Dim EmailServer
Dim EMailPort

Dim MyTypeMemo 
Dim MyTypeAutoincrement
Dim MyTablePrefix
Dim MyViewStatement
Dim MyAutoIndex
Dim MyAutoIndexGet



Dim  NtpServer

Dim XMLfileObj

Const HKEY_LOCAL_MACHINE = &H80000002 

' Below calls the config and tool files to setups.
on error resume next
Dim sScriptPath
sScriptPath = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile(sScriptPath & SuiteName & ".tools.vbs").ReadAll
If Err.Number <> 0 Then
			wscript.echo WScript.ScriptFullName & "::" & myScriptPath & SuiteName & ".tools.vbs " & Err.Number & " -- " &  Err.Description
			Err.Clear
End If
ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile(sScriptPath & SuiteName & ".tools-XML.vbs").ReadAll
If Err.Number <> 0 Then
			wscript.echo WScript.ScriptFullName & "::" & myScriptPath & SuiteName & ".tools.vbs " & Err.Number & " -- " &  Err.Description
			Err.Clear
End If

Dim myScriptNameExExt
Dim myScriptNameExExtExt
myScriptNameExExt=Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName,".") -1)
myScriptNameExExtExt=Left(myScriptNameExExt,InStrRev(myScriptNameExExt,".")-1)
'wscript.echo WScript.ScriptFullName & "::" & ("myScriptNameExExtExt " & myScriptNameExExtExt & ".conf.vbs")
'wscript.echo WScript.ScriptFullName & "::" & ("myScriptNameExExt " & myScriptNameExExt & ".conf.vbs")
ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile(myScriptNameExExtExt & ".conf.vbs").ReadAll
If Err.Number <> 0 Then
			wscript.echo WScript.ScriptFullName & "::" & myScriptNameExExtExt & ".conf.vbs " & Err.Number & " -- " &  Err.Description
			Err.Clear
End If
ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile(myScriptNameExExt & ".conf.vbs").ReadAll
If Err.Number <> 0 Then
			wscript.echo WScript.ScriptFullName & "::" &  myScriptNameExExt & ".conf.vbs " & Err.Number & " -- " &  Err.Description
			Err.Clear
End If 

Call Main()

Public Sub Main()
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Dim rs
	
	ToolsTimerStart()
	
	DBOpen()
			
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Dim ComputerName : ComputerName = ComputerNameGet()
	Dim UserName : UserName = UserNameGet()
	Dim strComputer : strComputer = "."
	
	Call Audit (strComputer)
	
	logfileclose
End Sub


Function Audit(strComputer)
	Dim objWMIService
	Dim Comment
	Dim LongComment
	'''''''''''''''''''''''''''
	'   Who are we auditing   '
	'''''''''''''''''''''''''''
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Comment = "Box : " & strComputer
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	
	Dim ComputerName : ComputerName = ComputerNameGet()
	
	Dim ColItems
	Dim objItem
	Dim system_name
	Dim domain
	Dim system_ip
	Dim user_name
	Dim system_id_number
	Dim system_vendor
	Dim system_uuid	
	Dim wshNetwork
	
	Dim TableData(100,2)
	Dim TableWhere(20,2)
	Dim TableI 
	
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem In ColItems
		system_name = objItem.Name
		domain = objItem.Domain
	Next
	Set ColItems = objWMIService.ExecQuery("Select IPAddress from Win32_networkadapterconfiguration WHERE IPEnabled='TRUE'",,48)
	For Each objItem In ColItems
		system_ip = objItem.IPAddress(0)
	Next
	
	Set wshNetwork = WScript.CreateObject( "WScript.Network" )
	user_name = wshNetwork.userName
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct",,48)
	For Each objItem In ColItems
		system_id_number = clean(objItem.IdentifyingNumber)
		system_vendor = clean(objItem.Vendor)
		system_uuid = objItem.UUID
	Next
	On Error Goto 0
	
	Dim full_system_name
	Dim ns_ip
	
	full_system_name = LCase(system_name) & "." & LCase(domain)
	ns_ip = NSlookup(system_name)
	if DDEEVV = true then LogFileWrite ( full_system_name & " " & ns_ip & " System UUID: " & system_uuid )

	LongComment = ""
	'''''''''''''''''''''''''''
	'   Network Information   '
	'''''''''''''''''''''''''''
	Comment = "NetworkInfo"
	LongComment  = LongComment + Comment
	
	If Not DBCheckRunFrequency(DBGetTableName(Comment),"eComputer", ComputerNameGet()) Then 
		myDebug("no update needed, " & RUNFrequence & " not execced" )
		'LogFileWrite("no update needed, " & RUNFrequence & " not execced" )
		Exit Function
	End If
	
	set XMLfileObj =  XMLInit(ComputernameGet())
	'if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	On Error Resume Next 
	'n error goto 0
	Set ColItems = objWMIService.ExecQuery("select * from win32_networkadapterconfiguration WHERE IPEnabled='TRUE' " _
	& "AND ServiceName<>'AsyncMac' AND ServiceName<>'VMnetx' " _
	& "AND ServiceName<>'VMnetadapter' AND ServiceName<>'Rasl2tp' " _
	& "AND ServiceName<>'msloop' " _
	& "AND ServiceName<>'PptpMiniport' AND ServiceName<>'Raspti' " _
	& "AND ServiceName<>'NDISWan' AND ServiceName<>'NdisWan4' AND ServiceName<>'RasPppoe' " _
	& "AND ServiceName<>'NdisIP' AND ServiceName<>'' AND Description<>'PPP Adapter.'",,48)
	
	Dim net_mac
	Dim net_description
	Dim net_dhcp_enabled
	Dim net_dhcp_server
	Dim net_dns_host_name
	Dim net_dns_server
	Dim net_dns_server_2
	Dim net_ip
	Dim net_ip_subnet
	Dim net_wins_primary
	Dim net_wins_secondary
	Dim net_adapter_type
	Dim net_manufacturer
	Dim net_gateway
	Dim net_ip_address
	
	Dim objItem2
	Dim colItems2		
	Dim myIp

	Dim NicName, DNSDomain, DNSDomainSuffixSearchOrder,DNSServers,DomainDNSRegistrationEnabled,NICServiceName,WINSEnableLMHostsLookup
	Dim NicSpeed,NicDuplex,NicDuplexReg,WINSSecondaryServer,WINSHostLookupFile,WINSPrimaryServer
	dim tArray,i, NicDuplexArr, oWMI, oNDIS, oLink
		
	For Each objItem In ColItems
		
		net_gateway = objItem.DefaultIPGateway(0)
		net_ip = objItem.IPAddress(0)
		net_mac = objItem.MACAddress
		net_description = objItem.Description
		net_dhcp_enabled = objItem.DHCPEnabled
		net_dhcp_server = objItem.DHCPServer
		net_dns_host_name = objItem.DNSHostName
		If IsArray(objItem.DNSServerSearchOrder) Then
			net_dns_server = objItem.DNSServerSearchOrder(0)
			net_dns_server_2 = objItem.DNSServerSearchOrder(1)
		End If
		net_ip_subnet = objItem.IPSubnet(0)
		net_wins_primary = objItem.WINSPrimaryServer
		net_wins_secondary = objItem.WINSSecondaryServer
		Set colItems2 = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE MACAddress='" & objItem.MACAddress & "'",,48)
		For Each objItem2 In colItems2
			net_adapter_type = objItem2.AdapterType
			net_manufacturer = objItem2.Manufacturer
		Next
		' Below is to account for a NULL in various items
		if net_ip = "" then net_ip = "0.0.0.0"
		if isnull(net_dns_server_2) then net_dns_server_2 = "none"
		if isnull(net_dhcp_server) then net_dhcp_server = "none"
		if net_dhcp_server = "" then net_dhcp_server = "none"
		if isnull(net_dns_server) then net_dns_server = "none"
		if isnull(net_ip_subnet) then net_ip_subnet = "none"
		net_description = clean(net_description)
		' IP Address padded with zeros so it sorts properly
		myIp = Split(net_ip, ".", -1, 1)
		If myIp(0) <> "169" And myIp(1) <> "254" Then
			myIp(0) = Right("000" & myIp(0),3)
			myIp(1) = Right("000" & myIp(1),3)
			myIp(2) = Right("000" & myIp(2),3)
			myIp(3) = Right("000" & myIp(3),3)
			net_ip = myIp(0) & "." & myIp(1) & "." & myIp(2) & "." & myIp(3)
			if net_ip <> "000.000.000.000" then net_ip_address = net_ip End If
		End If
		'myDebug(net_gateway)
		if net_gateway = "" then net_gateway = "none"
		if isnull(net_ip_address) then net_ip_address = "" End If		
		
'========================================================================== 
' NAME: IPInfo.vbs 
' 
' Alan Kaplan, original version 11/26/2002 (not the best example of clean coding) 
' alan dot kaplan at va gov 
' COMMENT: First change, 2005 added link speed 
' 1-8-2007 Fixed DNS search order and added WAG for duplex setting. 
'========================================================================== 
		NicName = ""
		DNSDomain = ""	
		DNSDomainSuffixSearchOrder = ""
		
		DNSServers = ""
		DomainDNSRegistrationEnabled = ""
		NICServiceName = ""
		WINSEnableLMHostsLookup = ""
		NicSpeed = ""
		NicDuplex = ""
		WINSSecondaryServer = ""
		WINSHostLookupFile = ""
		WINSPrimaryServer = ""

		If objItem.IPAddress(0) <> "0.0.0.0" Then 
			tArray = split(objItem.Caption,"] ") 
			NicName = tArray(1) 
			mydebug ("NicName: " & NicName)
			DNSDomain = objItem.DNSDomain 
			mydebug ("DNSDomain: " & DNSDomain)
			If IsArray(objItem.DNSDomainSuffixSearchOrder) Then 
				DNSDomainSuffixSearchOrder = "" 
				For i = 0 To UBound(objItem.DNSDomainSuffixSearchOrder) 
					DNSDomainSuffixSearchOrder = DNSDomainSuffixSearchOrder & objItem.DNSDomainSuffixSearchOrder(i) 
					If i <> UBound(objItem.DNSDomainSuffixSearchOrder) Then DNSDomainSuffixSearchOrder  = DNSDomainSuffixSearchOrder & ", " 
				Next 
			Else 
					DNSDomainSuffixSearchOrder = DNSDomainSuffixSearchOrder  & objItem.DNSDomainSuffixSearchOrder 
			End If 
			mydebug ("DNSDomainSuffixSearchOrder: " & DNSDomainSuffixSearchOrder)
			WINSResolution = objItem.DNSEnabledForWINSResolution 
			mydebug ("WINSResolution: " & WINSResolution)
			For i = 0 to UBound(objItem.DNSServerSearchOrder) 
				DNSServers = DNSServers & objItem.DNSServerSearchOrder(i) & ","
			Next 
			mydebug ("DNSServers: " & DNSServers)
			DomainDNSRegistrationEnabled  = objItem.DomainDNSRegistrationEnabled 
			mydebug ("DomainDNSRegistrationEnabled: " & DomainDNSRegistrationEnabled)
			NICServiceName = objItem.ServiceName 
			mydebug ("NICServiceName: " & NICServiceName)
			WINSEnableLMHostsLookup = objItem.WINSEnableLMHostsLookup
			mydebug ("WINSEnableLMHostsLookup: " & WINSEnableLMHostsLookup)
			WINSHostLookupFile = objItem.WINSHostLookupFile 
			mydebug ("WINSHostLookupFile: " & WINSHostLookupFile)
			WINSPrimaryServer = objItem.WINSPrimaryServer 
			mydebug ("WINSPrimaryServer: " & WINSPrimaryServer)
			WINSSecondaryServer = objItem.WINSSecondaryServer 
			mydebug ("WINSSecondaryServer: " & WINSSecondaryServer)
			'mydebug ("before NicDuplex() " & NicName)
			NicDuplex = NicGetDuplex (strcomputer,nicname)
			NicDuplexReg = NicLastNICLookupDetailDetails
			
			mydebug ("NicDuplexReg: " & NicDuplexReg)
			mydebug ("NicDuplex: " & NicDuplex)
			NicSpeed = NicLinkSpeedGet (strcomputer,nicname)
			mydebug ("NicSpeed: " & NicSpeed)
		End If 
		
		If net_dhcp_server <> "255.255.255.255" Then
				TableI = 0
				
				TableData (TableI,0) = "[NicName]" 						: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = NicName 					: TableI = TableI + 1
				TableData (TableI,0) = "[DNSDomain]" 					: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = DNSDomain 					: TableI = TableI + 1
				TableData (TableI,0) = "[DNSDomainSuffixSearchOrder]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = DNSDomainSuffixSearchOrder : TableI = TableI + 1
				TableData (TableI,0) = "[DNSServers]" 					: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = DNSServers 				: TableI = TableI + 1
				TableData (TableI,0) = "[DomainDNSRegistrationEnabled]" : TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = DomainDNSRegistrationEnabled : TableI = TableI + 1
				TableData (TableI,0) = "[NICServiceName]" 				: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = NICServiceName 			: TableI = TableI + 1
				TableData (TableI,0) = "[WINSEnableLMHostsLookup]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = WINSEnableLMHostsLookup 	: TableI = TableI + 1
				TableData (TableI,0) = "[WINSHostLookupFile]" 			: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = WINSHostLookupFile 					: TableI = TableI + 1
				TableData (TableI,0) = "[WINSPrimaryServer]" 			: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = WINSPrimaryServer 					: TableI = TableI + 1
				TableData (TableI,0) = "[WINSSecondaryServer]" 			: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = WINSSecondaryServer 					: TableI = TableI + 1
				TableData (TableI,0) = "[NicDuplex]" 					: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = NicDuplex 					: TableI = TableI + 1
				TableData (TableI,0) = "[NicSpeed]" 					: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = NicSpeed 					: TableI = TableI + 1
				TableData (TableI,0) = "[NicDuplexReg]" 				: TableData (TableI,1) =  MyTypeMemo 	: TableData (TableI,2) = NicDuplexReg					: TableI = TableI + 1						
				TableData (TableI,0) = "[net_mac]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_mac 					: TableI = TableI + 1
				TableData (TableI,0) = "[net_description]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_description 			: TableI = TableI + 1
				TableData (TableI,0) = "[net_dhcp_enabled]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_dhcp_enabled			: TableI = TableI + 1
				TableData (TableI,0) = "[net_dhcp_server]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_dhcp_server 			: TableI = TableI + 1
				TableData (TableI,0) = "[net_dns_host_name]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_dns_host_name			: TableI = TableI + 1
				TableData (TableI,0) = "[net_dns_server]"		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_dns_server				: TableI = TableI + 1
				TableData (TableI,0) = "[net_dns_server_2]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_dns_server_2			: TableI = TableI + 1
				TableData (TableI,0) = "[net_ip]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_ip						: TableI = TableI + 1
				TableData (TableI,0) = "[net_ip_subnet]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_ip_subnet				: TableI = TableI + 1
				TableData (TableI,0) = "[net_wins_primary]"	 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_wins_primary 			: TableI = TableI + 1
				TableData (TableI,0) = "[net_wins_secondary]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_wins_secondary			: TableI = TableI + 1
				TableData (TableI,0) = "[net_adapter_type]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_adapter_type			: TableI = TableI + 1
				TableData (TableI,0) = "[net_manufacturer]"	 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_manufacturer			: TableI = TableI + 1
				TableData (TableI,0) = "[net_gateway]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = net_gateway				: TableI = TableI + 1
				TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""
	
				TableWhere (0,0) = "[eComputer]" 				: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
				TableWhere (1,0) = "[net_mac]" 					: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = net_mac
				TableWhere (2,0) = "" 							: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

				XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
				DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
					
			if net_mac_uuid = "" then net_mac_uuid = net_mac End If
		End If
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")	
	
	Comment = "Domain"
	Dim net_domain
	Dim net_user_name
	Dim net_Caption
    Dim net_ClientSiteName
    Dim net_CreationClassName
    Dim net_DcSiteName
    Dim net_DCDescription
    Dim net_DnsForestName
    Dim net_DomainControllerAddress
    Dim net_DomainControllerAddressType
    Dim net_DomainControllerName
    Dim net_DomainGuid
    Dim net_DomainName
    Dim net_DSDirectoryServiceFlag
    Dim net_DSDnsControllerFlag
    Dim net_DSDnsDomainFlag
    Dim net_DSDnsForestFlag
    Dim net_DSGlobalCatalogFlag
    Dim net_DSKerberosDistributionCenterFlag
    Dim net_DSPrimaryDomainControllerFlag
    Dim net_DSTimeServiceFlag
    Dim net_DSWritableFlag
    Dim net_InstallDate
    Dim net_Name
    Dim net_NameFormat
    Dim net_PrimaryOwnerContact
    Dim net_PrimaryOwnerName
    Dim net_Roles
    Dim net_Status
	
	Dim oReg
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
	
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem In ColItems
		net_domain = objItem.Domain
		net_user_name = objItem.UserName
	Next
	
	If IsNull(net_domain) Then
		oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", net_domain
		if isnull(net_domain) then net_domain = "" End If
	End If
	If IsNull(net_user_name) Then
		oReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", net_user_name
		if isnull(net_user_name) then net_user_name = "" End If
	End If
	if isnull(net_domain) then net_domain = "" End if
	if isnull(net_user_name) then net_user_name = "" End if
	
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_NTDomain",,48)
	For Each objItem In ColItems
		net_Caption = objItem.Caption
	    net_ClientSiteName = objItem.ClientSiteName
	    net_CreationClassName = objItem.CreationClassName
	    net_DcSiteName = objItem.DcSiteName
	    net_DCDescription = objItem.Description
	    net_DnsForestName = objItem.DnsForestName
	    net_DomainControllerAddress = objItem.DomainControllerAddress
	    net_DomainControllerAddressType = objItem.DomainControllerAddressType
	    net_DomainControllerName = objItem.DomainControllerName
		net_DomainGuid = objItem.DomainGuid
	    net_DomainName = objItem.DomainName
	    net_DSDirectoryServiceFlag = objItem.DSDirectoryServiceFlag
	    net_DSDnsControllerFlag = objItem.DSDnsControllerFlag
	    net_DSDnsDomainFlag = objItem.DSDnsDomainFlag
	    net_DSDnsForestFlag = objItem.DSDnsForestFlag
	    net_DSGlobalCatalogFlag = net_DSGlobalCatalogFlag
	    net_DSKerberosDistributionCenterFlag = objItem.DSKerberosDistributionCenterFlag
	    net_DSPrimaryDomainControllerFlag = objItem.DSPrimaryDomainControllerFlag
	    net_DSTimeServiceFlag = objItem.DSTimeServiceFlag
	    net_DSWritableFlag = objItem.DSWritableFlag
	    net_InstallDate = objItem.InstallDate
	    net_Name = objItem.Name
	    net_NameFormat = objItem.NameFormat
	    net_PrimaryOwnerContact = objItem.PrimaryOwnerContact
	    net_PrimaryOwnerName = objItem.PrimaryOwnerName
		if isarray(objItem.Roles) then 
			net_Roles = Join(objItem.Roles, ", ") 
		else
			net_Roles = objItem.Roles
		end if
	    net_Status = objItem.Status
		
		if isnull(net_Caption) then net_Caption = "" End if
		if isnull(net_ClientSiteName) then net_ClientSiteName = "" End if
	    if isnull(net_CreationClassName) then net_CreationClassName = "" End if
	    if isnull(net_DcSiteName) then net_DcSiteName = "" End if
	    if isnull(net_DCDescription) then net_DCDescription = "" End if
	    if isnull(net_DnsForestName) then net_DnsForestName = "" End if
	    if isnull(net_DomainControllerAddress) then net_DomainControllerAddress = "" End if
	    if isnull(net_DomainControllerAddressType) then net_DomainControllerAddressType = "" End if
	    if isnull(net_DomainControllerName) then net_DomainControllerName = "" End if
	    if isnull(net_DomainGuid) then net_DomainGuid = "" End if
	    if isnull(net_DomainName) then net_DomainName = "" End if
	    if isnull(net_DSDirectoryServiceFlag) then net_DSDirectoryServiceFlag = "" End if
	    if isnull(net_DSDnsControllerFlag) then net_DSDnsControllerFlag = "" End if
	    if isnull(net_DSDnsDomainFlag) then net_DSDnsDomainFlag = "" End if
	    if isnull(net_DSDnsForestFlag) then net_DSDnsForestFlag = "" End if
	    if isnull(net_DSGlobalCatalogFlag) then net_DSGlobalCatalogFlag = "" End if
	    if isnull(net_DSKerberosDistributionCenterFlag) then net_DSKerberosDistributionCenterFlag = "" End if
	    if isnull(net_DSPrimaryDomainControllerFlag) then net_DSPrimaryDomainControllerFlag = "" End if
	    if isnull(net_DSTimeServiceFlag) then net_DSTimeServiceFlag = "" End if
	    if isnull(net_DSWritableFlag) then net_DSWritableFlag = "" End if
	    if isnull(net_InstallDate) then net_InstallDate = "" End if
	    if isnull(net_Name) then net_Name = "" End if
	    if isnull(net_NameFormat) then net_NameFormat = "" End if
	    if isnull(net_PrimaryOwnerContact) then net_PrimaryOwnerContact = "" End if
	    if isnull(net_PrimaryOwnerName) then net_PrimaryOwnerName = "" End if
	    if isnull(net_Roles) then net_Roles = "" End if
	    if isnull(net_Status) then net_Status = "" End if
		
		TableI = 0
		TableData (TableI,0) = "[net_ip_address]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_ip_address)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_user_name]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_user_name)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_Caption]" 				: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_Caption)			: TableI = TableI + 1
		TableData (TableI,0) = "[net_ClientSiteName]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_ClientSiteName)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_CreationClassName]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_CreationClassName)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DcSiteName]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DcSiteName)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DCDescription]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DCDescription)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DnsForestName]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DnsForestName)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_DomainControllerAddress]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(Replace(net_DomainControllerAddress, "\\", ""))		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DomainControllerAddressType]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(net_DomainControllerAddressType)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DomainControllerName]" : TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(Replace(net_DomainControllerName, "\\", ""))	: TableI = TableI + 1
		TableData (TableI,0) = "[net_DomainGuid]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DomainGuid)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DomainName]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DomainName)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSDirectoryServiceFlag]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(net_DSDirectoryServiceFlag)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSDnsControllerFlag]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSDnsControllerFlag)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSDnsDomainFlag]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSDnsDomainFlag)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSDnsForestFlag]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSDnsForestFlag)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSGlobalCatalogFlag]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSGlobalCatalogFlag)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSKerberosDistributionCenterFlag]" : TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(net_DSKerberosDistributionCenterFlag)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSPrimaryDomainControllerFlag]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(net_DSPrimaryDomainControllerFlag)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSTimeServiceFlag]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSTimeServiceFlag)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_DSWritableFlag]" 		: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_DSWritableFlag)	: TableI = TableI + 1
		TableData (TableI,0) = "[net_InstallDate]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_InstallDate)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_Name]" 				: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_Name)			: TableI = TableI + 1
		TableData (TableI,0) = "[net_NameFormat]" 			: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_NameFormat)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_PrimaryOwnerContact]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_PrimaryOwnerContact)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_PrimaryOwnerName]" 	: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_PrimaryOwnerName)		: TableI = TableI + 1
		TableData (TableI,0) = "[net_Roles]" 				: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_Roles)			: TableI = TableI + 1
		TableData (TableI,0) = "[net_Status]" 				: TableData (TableI,1) =  MyTypeMemo  		: TableData (TableI,2) = clean(net_Status)			: TableI = TableI + 1
		TableData (TableI,0) = "" 								: TableData (TableI,1) = "" 				: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[net_Caption]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(net_Caption)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 	
	Next
	
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")

	'''''''''''''''''''''''''''''''''''''
	'   System Information  & Timezone  '
	'''''''''''''''''''''''''''''''''''''
	Dim system_model
	Dim system_num_processors
	Dim system_part_of_domain
	Dim system_primary_owner_name
	Dim system_system_type
	Dim mem_size
	Dim domain_role_text
	Dim tm_zone
	Dim tm_daylight
	Dim mem_count
	
	Comment = "SystemInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_LogicalMemoryConfiguration",,48)
	mem_count = 0
	On Error Resume Next
	For Each objItem In ColItems
			mem_count = mem_count + objItem.Capacity
	Next
	If mem_count > 0 Then
		mem_size = Int(mem_count /1024 /1024)
	Else
		Set ColItems = objWMIService.ExecQuery("Select * from Win32_LogicalmemoryConfiguration",,48)
		For Each objItem In ColItems
			mem_size = objItem.TotalPhysicalmemory
		Next
		mem_size = Int(mem_size /1024)
	End If
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem In ColItems
		system_model = clean(objItem.Model)
		system_name = clean(objItem.Name)
		system_num_processors = clean(objItem.NumberOfProcessors)
		system_part_of_domain = clean(objItem.PartOfDomain)
		system_primary_owner_name = clean(objItem.PrimaryOwnerName)
		domain_role = clean(objItem.DomainRole)
	Next
	if domain_role = "0" then domain_role_text = "Standalone Workstation" End If
	if domain_role = "1" then domain_role_text = "Workstation" End If
	if domain_role = "2" then domain_role_text = "Standalone Server" End If
	if domain_role = "3" then domain_role_text = "Member Server" End If
	if domain_role = "4" then domain_role_text = "Backup Domain Controller" End If
	if domain_role = "5" then domain_role_text = "Primary Domain Controller" End If

	Set ColItems = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure",,48)
	For Each objItem In ColItems
		system_system_type = Join(objItem.ChassisTypes, ",")
	Next

	Set ColItems = objWMIService.ExecQuery("Select * from Win32_TimeZone",,48)
	For Each objItem In ColItems
		tm_zone = clean(objItem.Caption)
		tm_daylight = clean(objItem.DaylightName)
	Next

	if system_system_type = "1" then system_system_type = "Other" End If
	if system_system_type = "2" then system_system_type = "Unknown" End If
	if system_system_type = "3" then system_system_type = "Desktop" End If
	if system_system_type = "4" then system_system_type = "Low Profile Desktop" End If
	if system_system_type = "5" then system_system_type = "Pizza Box" End If
	if system_system_type = "6" then system_system_type = "Mini Tower" End If
	if system_system_type = "7" then system_system_type = "Tower" End If
	if system_system_type = "8" then system_system_type = "Portable" End If
	if system_system_type = "9" then system_system_type = "Laptop" End If
	if system_system_type = "10" then system_system_type = "Notebook" End If
	if system_system_type = "11" then system_system_type = "Hand Held" End If
	if system_system_type = "12" then system_system_type = "Docking Station" End If
	if system_system_type = "13" then system_system_type = "All in One" End If
	if system_system_type = "14" then system_system_type = "Sub Notebook" End If
	if system_system_type = "15" then system_system_type = "Space-Saving" End If
	if system_system_type = "16" then system_system_type = "Lunch Box" End If
	if system_system_type = "17" then system_system_type = "Main System Chassis" End If
	if system_system_type = "18" then system_system_type = "Expansion Chassis" End If
	if system_system_type = "19" then system_system_type = "SubChassis" End If
	if system_system_type = "20" then system_system_type = "Bus Expansion Chassis" End If
	if system_system_type = "21" then system_system_type = "Peripheral Chassis" End If
	if system_system_type = "22" then system_system_type = "Storage Chassis" End If
	if system_system_type = "23" then system_system_type = "Rack Mount Chassis" End If
	if system_system_type = "24" then system_system_type = "Sealed-Case PC"  End If

	TableI = 0
	TableData (TableI,0) = "[system_model]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = Trim(system_model) 		: TableI = TableI + 1
	TableData (TableI,0) = "[system_name]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) =system_name					: TableI = TableI + 1
	TableData (TableI,0) = "[system_num_processors]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_num_processors 		: TableI = TableI + 1
	TableData (TableI,0) = "[system_part_of_domain]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_part_of_domain 		: TableI = TableI + 1
	TableData (TableI,0) = "[system_primary_owner_name]": TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_primary_owner_name	: TableI = TableI + 1
	TableData (TableI,0) = "[system_system_type]"		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_system_type			: TableI = TableI + 1
	TableData (TableI,0) = "[mem_size]"					: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = mem_size 					: TableI = TableI + 1
	TableData (TableI,0) = "[system_id_number]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_id_number			: TableI = TableI + 1
	TableData (TableI,0) = "[system_vendor]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = Trim(system_vendor) 		: TableI = TableI + 1
	TableData (TableI,0) = "[domain_role_text]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = domain_role_text 			: TableI = TableI + 1
	TableData (TableI,0) = "[tm_zone]"	 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = tm_zone 					: TableI = TableI + 1
	TableData (TableI,0) = "[tm_daylight]"				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = tm_daylight				: TableI = TableI + 1
	TableData (TableI,0) = "" 							: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""
	
	TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
	TableWhere (1,0) = "[system_id_number]" 	: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = system_id_number
	TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

	XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
	DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
							
	'''''''''''''''''''''''''''
	'   Windows Information   '
	'''''''''''''''''''''''''''
	Dim boot_device
	Dim build_number
	Dim OSType
	Dim OSName
	Dim Country
	Dim system_description
	Dim OSInstall
	Dim OSInstallYear
	Dim OSInstallMonth
	Dim OSInstallDay
	Dim RegOrg
	Dim OSLang
	Dim RegUser
	Dim SerNum
	Dim OSSerPack
	Dim Version
	Dim WinDir

	Dim ServicePack
	Dim SystemBuildNumber
	Dim sys_version
	Dim OSCaption
	
	Comment = "WindowsInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next

	Set ColItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
	For Each objItem In ColItems
	OSName = objItem.Caption
	If objItem.OSType = "16" Then
		OSName = "Microsoft Windows 95"
	End If
	If objItem.OSType = "17" Then
		OSName = "Microsoft Windows 98"
		If InStr(objItem.Name, "|") Then
			OSName = Left(objItem.Name, InStr(objItem.Name, "|") - 1)
		Else
			OSName = objItem.Name
		End If
	End If
	OSInstall = objItem.InstallDate
	OSInstall = Left(OSInstall, 8)
	OSInstallYear = Left(OSInstall, 4)
	OSInstallMonth = Mid(OSInstall, 5, 2)
	OSInstallDay = Right(OSInstall, 2)
	OSInstall = OSInstallYear & "/" & OSInstallMonth & "/" & OSInstallDay
	OSType = objItem.OSType
	ServicePack = objItem.ServicePackMajorVersion
	OSLang = objItem.OSLanguage
	SystemBuildNumber = objItem.BuildNumber
	sys_version = objItem.Version
	system_description = clean(objItem.Description)
	OSCaption = objItem.Caption
	RegUser = clean(objItem.RegisteredUser)
	WinDir = clean(objItem.WindowsDirectory)
	RegOrg = clean(objItem.Organization)
	Country = objItem.CountryCode
	SerNum = objItem.SerialNumber
	OSSerPack = objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion
	boot_device = clean(objItem.BootDevice)
	build_number = clean(objItem.BuildNumber)
	Version = objItem.Version
	Next
	
	TableI = 0
	TableData (TableI,0) = "[boot_device]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = boot_device					: TableI = TableI + 1
	TableData (TableI,0) = "[build_number]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = build_number 			: TableI = TableI + 1
	TableData (TableI,0) = "[OSType]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = OSType			: TableI = TableI + 1
	TableData (TableI,0) = "[OSName]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = OSName			: TableI = TableI + 1
	TableData (TableI,0) = "[Country]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = Country 			: TableI = TableI + 1
	TableData (TableI,0) = "[system_description]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = system_description				: TableI = TableI + 1
	TableData (TableI,0) = "[OSInstall]"			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = OSInstall		: TableI = TableI + 1
	TableData (TableI,0) = "[RegOrg]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = RegOrg			: TableI = TableI + 1
	TableData (TableI,0) = "[OSLang]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = OSLang						: TableI = TableI + 1
	TableData (TableI,0) = "[RegUser]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = RegUser				: TableI = TableI + 1
	TableData (TableI,0) = "[SerNum]"	 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = SerNum 			: TableI = TableI + 1
	TableData (TableI,0) = "[OSSerPack]"			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = OSSerPack			: TableI = TableI + 1
	TableData (TableI,0) = "[Version]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = Version			: TableI = TableI + 1
	TableData (TableI,0) = "[WinDir]"	 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = WinDir			: TableI = TableI + 1
	TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

	TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
	TableWhere (1,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

	XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
	DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")

	'''''''''''''''''''''''''''
	'   Bios Information      '
	'''''''''''''''''''''''''''
	Dim objSMBIOS
	Dim colSMBIOS
	Dim bios_asset
	
	Comment = "BiosInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next

	Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure",,48)
	For Each objSMBIOS In colSMBIOS
		bios_asset = objSMBIOS.SMBIOSAssetTag
	Next

	Set ColItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
			
	For Each objItem In ColItems

		TableI = 0
		TableData (TableI,0) = "[SerialNumber]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SerialNumber)		: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description)			: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer) 		: TableI = TableI + 1
		TableData (TableI,0) = "[SMBIOSBIOSVersion]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SMBIOSBIOSVersion) 	: TableI = TableI + 1
		TableData (TableI,0) = "[Version]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Version)				: TableI = TableI + 1
		TableData (TableI,0) = "[bios_asset]"			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(bios_asset)					: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""
		
		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[SerialNumber]" 		: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.SerialNumber)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	'''''''''''''''''''''''''''
	'   Processor Information '
	'''''''''''''''''''''''''''
	Dim count
	Comment = "ProcessorInfo"
	LongComment = LongComment + Comment
	
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
	count = 0
	
	For Each objItem In ColItems
		count = count + 1
		If count > Int(system_num_processors) Then
			Exit For
		End If
		
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)			: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption) 			: TableI = TableI + 1
		TableData (TableI,0) = "[CurrentClockSpeed]" 	: TableData (TableI,1) = "integer" 	: TableData (TableI,2) = clean(objItem.CurrentClockSpeed)	: TableI = TableI + 1
		TableData (TableI,0) = "[CurrentVoltage]" 		: TableData (TableI,1) = "integer" 	: TableData (TableI,2) = clean(objItem.CurrentVoltage)		: TableI = TableI + 1
		TableData (TableI,0) = "[ExtClock]" 			: TableData (TableI,1) = "integer" 	: TableData (TableI,2) = clean(objItem.ExtClock) 			: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]"			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer)		: TableI = TableI + 1
		TableData (TableI,0) = "[MaxClockSpeed]"		: TableData (TableI,1) = "integer" 	: TableData (TableI,2) = clean(objItem.MaxClockSpeed) 		: TableI = TableI + 1
		TableData (TableI,0) = "[Name]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = LTrim(clean(objItem.Name)) 		: TableI = TableI + 1
		TableData (TableI,0) = "[PowerManagementSupported]" : TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.PowerManagementSupported): TableI = TableI + 1
		TableData (TableI,0) = "[SocketDesignation]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SocketDesignation) 	: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""
		
		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	'''''''''''''''''''''''''''
	'   memory Information
	'''''''''''''''''''''''''''
	Dim system_memory_banks
	Dim mem_formfactor
	Dim mem_detail
	Dim mem_typedetail
	Dim mem_bank
	
	Comment = "MemoryInfo"
	LongComment = LongComment + Comment
	
	Set ColItems = objWMIService.ExecQuery("Select memoryDevices FROM Win32_PhysicalMemoryArray WHERE Use = '3'",,48)
	on error resume next
	For Each objItem In ColItems
		system_memory_banks = objItem.memoryDevices
	Next
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select Capacity,DeviceLocator,FormFactor,memoryType,TypeDetail,Speed FROM Win32_Physicalmemory",,48)
	mem_count = 0
	mem_size = 0

	on error resume next
	For Each objItem In ColItems
		if DDEEVV = true then On Error Goto 0 Else on error resume next	
		mem_count = mem_count + 1

		If mem_count > Int(system_memory_banks) Then
			Exit For
		End If

		If objItem.FormFactor = "7" Then
			mem_formfactor = "SIMM"
		ElseIf objItem.FormFactor = "8" Then
			mem_formfactor = "DIMM"
		ElseIf objItem.FormFactor = "11" Then
			mem_formfactor = "RIMM"
		ElseIf objItem.FormFactor = "12" Then
			mem_formfactor = "SODIMM"
		ElseIf objItem.FormFactor = "13" Then
			mem_formfactor = "SRIMM"
		Else
			mem_formfactor = "Unknown"
		End If

		If objItem.memoryType = "0" Then
			mem_detail = "Unknown"
		ElseIf objItem.memoryType = "1" Then
			mem_detail = "Other"
		ElseIf objItem.memoryType = "2" Then
			mem_detail = "DRAM"
		ElseIf objItem.memoryType = "3" Then
			mem_detail = "Synchronous DRAM"
		ElseIf objItem.memoryType = "4" Then
			mem_detail = "Cache DRAM"
		ElseIf objItem.memoryType = "5" Then
			mem_detail = "EDO"
		ElseIf objItem.memoryType = "6" Then
			mem_detail = "EDRAM"
		ElseIf objItem.memoryType = "7" Then
			mem_detail = "VRAM"
		ElseIf objItem.memoryType = "8" Then
			mem_detail = "SRAM"
		ElseIf objItem.memoryType = "9" Then
			mem_detail = "RAM"
		ElseIf objItem.memoryType = "10" Then
			mem_detail = "ROM"
		ElseIf objItem.memoryType = "11" Then
			mem_detail = "Flash"
		ElseIf objItem.memoryType = "12" Then
			mem_detail = "EEPROM"
		ElseIf objItem.memoryType = "13" Then
			mem_detail = "FEPROM"
		ElseIf objItem.memoryType = "14" Then
			mem_detail = "EPROM"
		ElseIf objItem.memoryType = "15" Then
			mem_detail = "CDRAM"
		ElseIf objItem.memoryType = "16" Then
			mem_detail = "3DRAM"
		ElseIf objItem.memoryType = "17" Then
			mem_detail = "SDRAM"
		ElseIf objItem.memoryType = "18" Then
			mem_detail = "SGRAM"
		ElseIf objItem.memoryType = "19" Then
			mem_detail = "RDRAM"
		ElseIf objItem.memoryType = "20" Then
			mem_detail = "DDR"
		End If

		If objItem.TypeDetail = "1" Then
			mem_typedetail = "Reserved"
		ElseIf objItem.TypeDetail = "2" Then
			mem_typedetail = "Other"
		ElseIf objItem.TypeDetail = "4" Then
			mem_typedetail = "Unknown"
		ElseIf objItem.TypeDetail = "8" Then
			mem_typedetail = "Fast-paged"
		ElseIf objItem.TypeDetail = "16" Then
			mem_typedetail = "Static column"
		ElseIf objItem.TypeDetail = "32" Then
			mem_typedetail = "Pseudo-static"
		ElseIf objItem.TypeDetail = "64" Then
			mem_typedetail = "RAMBUS"
		ElseIf objItem.TypeDetail = "128" Then
			mem_typedetail = "Synchronous"
		ElseIf objItem.TypeDetail = "256" Then
			mem_typedetail = "CMOS"
		ElseIf objItem.TypeDetail = "512" Then
			mem_typedetail = "EDO"
		ElseIf objItem.TypeDetail = "1024" Then
			mem_typedetail = "Window DRAM"
		ElseIf objItem.TypeDetail = "2048" Then
			mem_typedetail = "Cache DRAM"
		ElseIf objItem.TypeDetail = "4096" Then
			mem_typedetail = "Non-volatile"
		Else
			mem_typedetail = "Unknown"
		End If
		mem_bank = objItem.DeviceLocator
		mem_size = Int(objItem.Capacity /1024 /1024)
		
		TableI = 0
		TableData (TableI,0) = "[mem_bank]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mem_bank 				: TableI = TableI + 1
		TableData (TableI,0) = "[mem_formfactor]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mem_formfactor  		: TableI = TableI + 1
		TableData (TableI,0) = "[mem_detail]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mem_detail 			: TableI = TableI + 1
		TableData (TableI,0) = "[mem_typedetail]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mem_typedetail			: TableI = TableI + 1
		TableData (TableI,0) = "[mem_size]" 		: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = mem_size 				: TableI = TableI + 1
		TableData (TableI,0) = "[Speed]" 			: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.Speed)	: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[mem_bank]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = mem_bank
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	if DDEEVV = true then On Error Goto 0 Else on error resume next			
	If mem_size = 0 Then
		Set ColItems = objWMIService.ExecQuery("Select * from Win32_LogicalmemoryConfiguration",,48)
	
		on error resume next
		For Each objItem In ColItems
			mem_size = objItem.TotalPhysicalmemory
		Next
		mem_size = Int(mem_size /1024)
		
		if DDEEVV = true then On Error Goto 0 Else on error resume next	
		TableI = 0
		TableData (TableI,0) = "[mem_formfactor]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = "Unknown"  : TableI = TableI + 1
		TableData (TableI,0) = "[mem_detail]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = "Unknown"  : TableI = TableI + 1
		TableData (TableI,0) = "[mem_typedetail]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = "Unknown" 	: TableI = TableI + 1
		TableData (TableI,0) = "[mem_size]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mem_size 	: TableI = TableI + 1
		TableData (TableI,0) = "[Speed]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = "0"		: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[mem_bank]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = "Unknown" 
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
		
	End If
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	'''''''''''''''''''''''''''
	'   Video Information     '
	'''''''''''''''''''''''''''
	
	Dim leftstring
	Comment = "VideoInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_VideoController",,48)
	
	
	For Each objItem In ColItems
		If (InStr(objItem.Caption, "vnc") = 0 And InStr(objItem.Caption, "Innobec SideWindow") = 0) and InStr(objItem.Caption, "Unicenter Remote Control") = 0 Then
			leftstring = Left(objItem.DriverDate, 8)
				
			TableI = 0
			TableData (TableI,0) = "[DeviceID]" 					: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)				: TableI = TableI + 1
			TableData (TableI,0) = "[AdapterRAM]" 					: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = Int(objItem.AdapterRAM / 1024 / 1024)	: TableI = TableI + 1
			TableData (TableI,0) = "[Caption]" 						: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption) 				: TableI = TableI + 1
			TableData (TableI,0) = "[CurrentHorizontalResolution]" 	: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.CurrentHorizontalResolution) : TableI = TableI + 1
			TableData (TableI,0) = "[CurrentNumberOfColors]"		: TableData (TableI,1) = MyTypeMemo 	: TableData (TableI,2) = clean(objItem.CurrentNumberOfColors) 	: TableI = TableI + 1
			TableData (TableI,0) = "[CurrentRefreshRate]"			: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.CurrentRefreshRate) 		: TableI = TableI + 1
			TableData (TableI,0) = "[CurrentVerticalResolution]"	: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.CurrentVerticalResolution) 	: TableI = TableI + 1
			TableData (TableI,0) = "[Description]" 					: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description)				: TableI = TableI + 1
			TableData (TableI,0) = "[DriverDate]" 					: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = Left(LeftString, 4) & "/" & Mid(LeftString, 5, 2) & "/" & Right(LeftString, 2) 				: TableI = TableI + 1
			TableData (TableI,0) = "[DriverVersion]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DriverVersion)			: TableI = TableI + 1
			TableData (TableI,0) = "[MaxRefreshRate]"	 			: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.MaxRefreshRate) 			: TableI = TableI + 1
			TableData (TableI,0) = "[MinRefreshRate]"				: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.MinRefreshRate)			: TableI = TableI + 1
			TableData (TableI,0) = "" 								: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""
			TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
			TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
			TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

			XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
			DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	
		End If
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	'''''''''''''''''''''''
	' Monitor Information '
	'''''''''''''''''''''''
	Dim intMonitorCount
	Dim sBaseKey
	Dim sBaseKey2
	Dim sBaseKey3
	Dim iRC
	Dim iRC2
	Dim iRC3
	Dim tmpctr
	Dim sKey
	Dim sKey2
	Dim sKey3 
	Dim arSubKeys3
	Dim arSubKeys2
	Dim arSubKeys
	Dim strRawEDID
	Dim bytevalue 
	Dim arrintedid
	Dim temp_manuf
	Dim temp_model
	Dim sValue

	
	Comment = "MonitorInfo"
	Dim strarrRawEDID()
	intMonitorCount=0
	Const HKLM = &H80000002
	

	sBaseKey = "SYSTEM\CurrentControlSet\Enum\DISPLAY\"
	iRC = oReg.EnumKey(HKLM, sBaseKey, arSubKeys)

	For Each sKey In arSubKeys
	sBaseKey2 = sBaseKey & sKey & "\"
	iRC2 = oReg.EnumKey(HKLM, sBaseKey2, arSubKeys2)
	For Each sKey2 In arSubKeys2
		oReg.GetMultiStringValue HKLM, sBaseKey2 & sKey2 & "\", "HardwareID", sValue
		For tmpctr=0 To UBound(svalue)
		If LCase(Left(sValue(tmpctr),8))="monitor\" Then
			sBaseKey3 = sBaseKey2 & sKey2 & "\"
			iRC3 = oReg.EnumKey(HKLM, sBaseKey3, arSubKeys3)
			For Each sKey3 In arSubKeys3
			If sKey3="Control" Then
				oReg.GetStringValue HKLM, sbasekey3, "DeviceDesc", temp_model
				oReg.GetStringValue HKLM, sbasekey3, "Mfg", temp_manuf
				oReg.GetBinaryValue HKLM, sBaseKey3 & "Device Parameters\", "EDID", arrintedid
				If VarType(arrintedid) <> 8204 Then
					strRawEDID="EDID Not Available"
				Else
				For Each bytevalue In arrintedid
					strRawEDID=strRawEDID & Chr(bytevalue)
				Next
				End If
				ReDim Preserve strarrRawEDID(intMonitorCount)
				strarrRawEDID(intMonitorCount)=strRawEDID
				intMonitorCount=intMonitorCount+1
			End If
			Next
		End If
		Next
	Next
	Next

	Dim arrMonitorInfo()
	Dim intSerFoundAt
	Dim intMdlFoundAt
	Dim findit
	Dim tmpser
	ReDim arrMonitorInfo(intMonitorCount-1,5)
	Dim location(3)
	Dim tmpmdl
	
	Dim tmpmfgweek
	Dim tmpmfgyear
	Dim tmpmdt
	Dim tmpEDIDMajorVer
	Dim tmpEDIDRev
	Dim tmpver
	Dim tmpdev
	Dim tmpEDIDMfg
	Dim Char1,Char2,Char3
	Dim Byte1,Byte2
	Dim strSerFind
	Dim strMdlFind
	Dim tmp
	Dim tmpmfg
	Dim tmpEDIDDev1
	Dim tmpEDIDDev2
	
	Dim man_id 
	Dim dev_id 
	Dim man_dt 
	Dim mon_sr 
	Dim mon_md 
	Dim mon_ed
	
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	For tmpctr=0 To intMonitorCount-1
	'tmpctr=0
	If strarrRawEDID(tmpctr) <> "EDID Not Available" Then
		location(0)=Mid(strarrRawEDID(tmpctr),&H36+1,18)
		location(1)=Mid(strarrRawEDID(tmpctr),&H48+1,18)
		location(2)=Mid(strarrRawEDID(tmpctr),&H5a+1,18)
		location(3)=Mid(strarrRawEDID(tmpctr),&H6c+1,18)
		strSerFind=Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&Hff)
		strMdlFind=Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&Hfc)
		intSerFoundAt=-1
		intMdlFoundAt=-1
		For findit = 0 To 3
		If InStr(location(findit),strSerFind)>0 Then
			intSerFoundAt=findit
		End If
		If InStr(location(findit),strMdlFind)>0 Then
			intMdlFoundAt=findit
		End If
		Next
		if intSerFoundAt<>-1 Then tmp=Right(location(intSerFoundAt),14)
		If InStr(tmp,Chr(&H0a))>0 Then
		tmpser=Trim(Left(tmp,InStr(tmp,Chr(&H0a))-1))
		Else
		tmpser=Trim(tmp)
		End If
		If Left(tmpser,1)=Chr(0) Then
		tmpser=Right(tmpser,Len(tmpser)-1)
		Else
		tmpser="Serial Number Not Found in EDID data"
		End If
		if intMdlFoundAt<>-1 Then tmp=Right(location(intMdlFoundAt),14)
		If InStr(tmp,Chr(&H0a))>0 Then
		tmpmdl=Trim(Left(tmp,InStr(tmp,Chr(&H0a))-1))
		Else
		tmpmdl=Trim(tmp)
		End If
		If Left(tmpmdl,1)=Chr(0) Then
		tmpmdl=Right(tmpmdl,Len(tmpmdl)-1)
		Else
		tmpmdl="Model Descriptor Not Found in EDID data"
		End If
		tmpmfgweek=Asc(Mid(strarrRawEDID(tmpctr),&H10+1,1))
		tmpmfgyear=(Asc(Mid(strarrRawEDID(tmpctr),&H11+1,1)))+1990
		tmpmdt=Month(DateAdd("ww",tmpmfgweek,DateValue("1/1/" & tmpmfgyear))) & "/" & tmpmfgyear
		tmpEDIDMajorVer=Asc(Mid(strarrRawEDID(tmpctr),&H12+1,1))
		tmpEDIDRev=Asc(Mid(strarrRawEDID(tmpctr),&H13+1,1))
		if tmpEDIDMajorVer >= 255 or tmpEDIDRev >= 255 then
			tmpver=tmpEDIDMajorVer & "." & tmpEDIDRev
		else
			tmpver=Chr(48+tmpEDIDMajorVer) & "." & Chr(48+tmpEDIDRev)
		end if
		tmpEDIDMfg=Mid(strarrRawEDID(tmpctr),&H08+1,2)
		Char1=0 : Char2=0 : Char3=0
		Byte1=Asc(Left(tmpEDIDMfg,1))
		Byte2=Asc(Right(tmpEDIDMfg,1))
		if (Byte1 and 64) > 0 then Char1=Char1+16
		if (Byte1 and 32) > 0 then Char1=Char1+8
		if (Byte1 and 16) > 0 then Char1=Char1+4
		if (Byte1 and 8) > 0 then Char1=Char1+2
		if (Byte1 and 4) > 0 then Char1=Char1+1
		if (Byte1 and 2) > 0 then Char2=Char2+16
		if (Byte1 and 1) > 0 then Char2=Char2+8
		if (Byte2 and 128) > 0 then Char2=Char2+4
		if (Byte2 and 64) > 0 then Char2=Char2+2
		if (Byte2 and 32) > 0 then Char2=Char2+1
		Char3=Char3+(Byte2 And 16)
		Char3=Char3+(Byte2 And 8)
		Char3=Char3+(Byte2 And 4)
		Char3=Char3+(Byte2 And 2)
		Char3=Char3+(Byte2 And 1)
		tmpmfg=Chr(Char1+64) & Chr(Char2+64) & Chr(Char3+64)
		tmpEDIDDev1=Hex(Asc(Mid(strarrRawEDID(tmpctr),&H0a+1,1)))
		tmpEDIDDev2=Hex(Asc(Mid(strarrRawEDID(tmpctr),&H0b+1,1)))
		if len(tmpEDIDDev1)=1 then tmpEDIDDev1="0" & tmpEDIDDev1
		if len(tmpEDIDDev2)=1 then tmpEDIDDev2="0" & tmpEDIDDev2
		tmpdev=tmpEDIDDev2 & tmpEDIDDev1
		' Accounts for model
		if (tmpmdl = "Model Descriptor Not Found in EDID data" AND temp_model <> "") then tmpmdl = temp_model End If
		if (tmpmdl = ""  AND temp_model <> "") then tmpmdl = temp_model End If
		if (tmpmdl = ""  AND temp_model =  "") then tmpmdl = "Model Descriptor Not Found in EDID data"
		' Account for serial
		if tmpser = "" then tmpser = "Serial Number Not Found in EDID data"
		' Accounts for manufacturer
		if (temp_manuf <> "(Standard monitor types)" AND temp_manuf <> "") then tmpmfg = temp_manuf
		arrMonitorInfo(tmpctr,0)=tmpmfg
		arrMonitorInfo(tmpctr,1)=tmpdev
		arrMonitorInfo(tmpctr,2)=tmpmdt
		arrMonitorInfo(tmpctr,3)=tmpser
		arrMonitorInfo(tmpctr,4)=tmpmdl
		arrMonitorInfo(tmpctr,5)=tmpver

		man_id = clean(arrMonitorInfo(tmpctr,0))
		dev_id = clean(arrMonitorInfo(tmpctr,1))
		man_dt = clean(arrMonitorInfo(tmpctr,2))
		mon_sr = clean(arrMonitorInfo(tmpctr,3))
		mon_md = clean(arrMonitorInfo(tmpctr,4))
		mon_md = escape(mon_md)
		mon_md = Replace(mon_md, "%00", "")
		mon_md = unescape(mon_md)
		mon_ed = clean(arrMonitorInfo(tmpctr,5))

		' Inserts a 0 if month < 10
		Dim temp_date
		temp_date = Split(man_dt, "/", -1, 1)
		temp_date(0) = Right("0" & temp_date(0),2)
		man_dt = temp_date(0) & "/" & temp_date(1)
		If man_id <> "" Then
		
		TableI = 0
		TableData (TableI,0) = "[dev_id]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = dev_id			: TableI = TableI + 1
		TableData (TableI,0) = "[man_id]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = man_id 		: TableI = TableI + 1
		TableData (TableI,0) = "[man_dt]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = man_dt			: TableI = TableI + 1
		TableData (TableI,0) = "[mon_md]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mon_md 		: TableI = TableI + 1
		TableData (TableI,0) = "[mon_sr]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mon_sr 		: TableI = TableI + 1
		TableData (TableI,0) = "[mon_ed]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mon_ed			: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[dev_id]" 				: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = dev_id
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 

		End If
	End If
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	''''''''''''''''''''''''
	' USB Attached Devices '
	''''''''''''''''''''''''
	Dim colDevices 
	Dim strDeviceName
	Dim strQuotes
	Dim arrDeviceNames
	Dim colUSBDevices
	Dim objUSBDevice
	Dim objDevice
	Dim name

	Comment = "USBDevices"
	
	Set colDevices = objWMIService.ExecQuery ("Select * From Win32_USBControllerDevice")
	
	For Each objDevice In colDevices
		strDeviceName = objDevice.Dependent
		strQuotes = Chr(34)
		strDeviceName = Replace(strDeviceName, strQuotes, "")
		arrDeviceNames = Split(strDeviceName, "=")
		strDeviceName = arrDeviceNames(1)
		Set colUSBDevices = objWMIService.ExecQuery ("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
		For Each objUSBDevice In colUSBDevices
			If ((objUSBDevice.Description <> "USB Root Hub") And _
				(objUSBDevice.Description <> "HID-compliant mouse") And _
				(objUSBDevice.Description <> "Generic USB Hub") And _
				(objUSBDevice.Description <> "Generic volume") And _
				(objUSBDevice.Description <> "USB Mass Storage Device") And _
				(objUSBDevice.Description <> "HID-compliant device") And _
				(objUSBDevice.Description <> "USB Human Interface Device") And _
				(objUSBDevice.Description <> "HID Keyboard Device") And _
				(objUSBDevice.Description <> "USB Composite Device") And _
				(objUSBDevice.Description <> "HID-compliant consumer control device") And _
				(objUSBDevice.Description <> "USB Mass Storage Device") And _
				(objUSBDevice.Description <> "USB Printing Support")) Then
				If name <> objUSBDevice.Caption Then
					TableI = 0
					TableData (TableI,0) = "[USBDeviceID]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objUSBDevice.DeviceID)	: TableI = TableI + 1
					TableData (TableI,0) = "[USBCaption]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objUSBDevice.Caption) 	: TableI = TableI + 1
					TableData (TableI,0) = "[USBDescription]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objUSBDevice.Description): TableI = TableI + 1
					TableData (TableI,0) = "[USBManufacturer]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objUSBDevice.Manufacturer) 	: TableI = TableI + 1
					TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

					TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
					TableWhere (1,0) = "[USBDeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objUSBDevice.DeviceID)
					TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

					XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
					DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
				End If
			End If
		Next
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")				
	

	'''''''''''''''''''''''''''
	'   H.Drive Information   '
	'''''''''''''''''''''''''''
	Comment = "HardDiskInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive",,48)
	
	
	For Each objItem In ColItems
	
		TableI = 0
		TableData (TableI,0) = "[Index]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Index)				: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption) 			: TableI = TableI + 1
		TableData (TableI,0) = "[InterfaceType]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.InterfaceType)		: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer)		: TableI = TableI + 1
		TableData (TableI,0) = "[Model]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Model) 				: TableI = TableI + 1
		TableData (TableI,0) = "[Partitions]"		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Partitions)			: TableI = TableI + 1
		TableData (TableI,0) = "[SCSIBus]"			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SCSIBus) 			: TableI = TableI + 1
		TableData (TableI,0) = "[SCSILogicalUnit]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SCSILogicalUnit)		: TableI = TableI + 1
		TableData (TableI,0) = "[SCSIPort]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.SCSIPort)			: TableI = TableI + 1
		TableData (TableI,0) = "[Size]" 			: TableData (TableI,1) = "integer" 	: TableData (TableI,2) = clean(Int(objItem.Size /1024 /1024)) : TableI = TableI + 1
		TableData (TableI,0) = "[PNPDeviceID]"	 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.PNPDeviceID) 		: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[Index]" 				: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.Index)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")				
	
	'''''''''''''''''''''''''''
	'   Partition Information '
	'''''''''''''''''''''''''''
	Comment = "PartitionInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next

	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_DiskPartition WHERE DriveType=3",,48)
	
	Dim partition_bootable
	Dim	partition_device_id
	Dim	partition_disk_index
	Dim	partition_index
	Dim	partition_primary_partition
	Dim partition_boot_partition
	
	On Error Resume Next
	For Each objItem In ColItems
		partition_bootable = objItem.Bootable
		if ((partition_bootable <> "True") OR isnull(partition_bootable)) then partition_bootable = "False" End If
		partition_boot_partition = objItem.BootPartition
		if ((partition_boot_partition <> "True") OR isnull(partition_boot_partition)) then partition_boot_partition = "False" End If
		partition_device_id = objItem.DeviceID
		partition_disk_index = objItem.DiskIndex
		partition_index = objItem.Index
		partition_primary_partition = objItem.PrimaryPartition
	Next
	Dim partition_caption
	Dim partition_file_system
	Dim partition_free_space
	Dim partition_size
	Dim partition_volume_name
	Dim partition_percent
		
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3",,48)
	
	For Each objItem In ColItems
		partition_caption = objItem.Caption
		partition_file_system = objItem.FileSystem
		partition_free_space = 0
		partition_free_space = Int(objItem.FreeSpace /1024 /1024)
		partition_size = 0
		partition_size = Int(objItem.Size /1024 /1024)
		partition_volume_name = objItem.VolumeName
		partition_percent = 0
		partition_percent = Round(((partition_size - partition_free_space) / partition_size) * 100 ,0)
		
		TableI = 0
		TableData (TableI,0) = "[partition_device_id]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_device_id		: TableI = TableI + 1
		TableData (TableI,0) = "[partition_caption]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_caption 			: TableI = TableI + 1
		TableData (TableI,0) = "[partition_bootable]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_bootable 		: TableI = TableI + 1
		TableData (TableI,0) = "[partition_boot_partition]" : TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_boot_partition	: TableI = TableI + 1
		TableData (TableI,0) = "[partition_disk_index]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_disk_index		: TableI = TableI + 1
		TableData (TableI,0) = "[partition_percent]"		: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = partition_percent			: TableI = TableI + 1
		TableData (TableI,0) = "[partition_primary_partition]"	: TableData (TableI,1) =  MyTypeMemo : TableData (TableI,2) = partition_primary_partition: TableI = TableI + 1
		TableData (TableI,0) = "[partition_file_system]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_file_system		: TableI = TableI + 1
		TableData (TableI,0) = "[partition_free_space]" 	: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = partition_free_space		: TableI = TableI + 1
		TableData (TableI,0) = "[partition_size]" 			: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = partition_size 			: TableI = TableI + 1
		TableData (TableI,0) = "[partition_volume_name]"	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = partition_volume_name  	: TableI = TableI + 1
		TableData (TableI,0) = "" 							: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[partition_device_id]" 	: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = partition_device_id	
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
		if partition_percent > 92 then
			dim mymessage : mymessage = "Partition " & partition_caption & " off " & UserNameGet() & "@" &  ComputerName & " is " & partition_percent & "% full (" & partition_free_space & "/" & partition_size &")" 
			dim htmlbody
			htmlbody = HTMBoSt()
			htmlbody = htmlbody & "<br>" 
			htmlbody = htmlbody & "<h2>" & mymessage & "</h2><hr>"
			htmlbody = htmlbody & HTMTbSt()
			htmlbody = htmlbody & HTMTRSt() &  HTMTHSt() & "please assist User!" & HTMTDEn() & HTMTREn()
			htmlbody = htmlbody & HTMTbEn()
			htmlbody = htmlbody & HTMBoEn()			
			LogFileWrite ("Mail Sent: " & SuiteName & "."& SuiteProg & " " & strFileName  & " can not be created!")
			if DDEEVV = true then myDebug("Mail Sent: " & SuiteName & "."& SuiteProg & " " & strFileName & " can not be created!")
			on error goto 0
			Call SendMail (SuiteName &"."&SuiteProg & " " &  mymessage,htmlbody, "")
			logfilewrite(mymessage)
		end if 
		
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
					
							
	'''''''''''''''''''''''''''''''''
	'   SCSI Cards                  '
	'''''''''''''''''''''''''''''''''
	Comment = "SCSICards"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_SCSIController",,48)

	For Each objItem In ColItems
		
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)		: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption)			: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer)	: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")					
	

	''''''''''''''''''
	'   SCSI Devices '
	''''''''''''''''''
	Comment = "SCSIDevices"
	LongComment = LongComment + Comment
	
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_SCSIControllerDevice",,48)
	
	For Each objItem In ColItems
		
		TableI = 0
		TableData (TableI,0) = "[Antecedent]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Antecedent) 	: TableI = TableI + 1
		TableData (TableI,0) = "[Dependent]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Dependent)	: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[Antecedent]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.Antecedent)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 	
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")

						
	'''''''''''''''''''''''''''''''''
	'   Optical Drive Information   '
	'''''''''''''''''''''''''''''''''
	Comment = "OpticalDriveInfo"
	LongComment = LongComment + Comment
	
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive",,48)
	On Error Resume Next
	For Each objItem In ColItems
		
		TableI = 0
		TableData (TableI,0) = "[DeviceID]"		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Device) 	: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption)		: TableI = TableI + 1
		TableData (TableI,0) = "[Drive]"		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Drive)		: TableI = TableI + 1
		TableData (TableI,0) = "" 				: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	'''''''''''''''''''
	'  Floppy Drives  '
	'''''''''''''''''''
	Comment = "FloppyDrives"
	LongComment = LongComment + Comment
	Set ColItems = objWMIService.ExecQuery("SELECT * FROM Win32_FloppyDrive",,48)
		
	For Each objItem In ColItems
		
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceI)		: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description) : TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer): TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption) 	: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""
		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	

	'''''''''''''''''''''''''''
	'   Tape Information      '
	'''''''''''''''''''''''''''
	Comment = "TapeDriveInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next

	Set ColItems = objWMIService.ExecQuery("Select * from Win32_TapeDrive",,48)
	
	For Each objItem In ColItems
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)	: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Caption)			: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description)			: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer) 			: TableI = TableI + 1
		TableData (TableI,0) = "[Name]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) =	clean(objItem.Name)			: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")

	'''''''''''''''''''''''''''
	'   Keyboard Information  '
	'''''''''''''''''''''''''''
	Comment = "KeyboardInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_Keyboard",,48)
				
	For Each objItem In ColItems
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)		: TableI = TableI + 1
		TableData (TableI,0) = "[Caption]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) =  clean(objItem.Caption)		: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description) 	: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	
	'''''''''''''''''''''''''''
	'   Battery Information   '
	'''''''''''''''''''''''''''
	Comment = "BatteryInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_Battery",,48)
		
	For Each objItem In ColItems
	
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) =  clean(objItem.DeviceID)			: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 			: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description)			: TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")				

	'''''''''''''''''''''''''''
	'   Modem Information     '
	'''''''''''''''''''''''''''
	Comment = "ModemInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_POTSModem",,48)
	
	For Each objItem In ColItems
	
		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)		: TableI = TableI + 1
		TableData (TableI,0) = "[boot_device]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.AttachedTo)		: TableI = TableI + 1
		TableData (TableI,0) = "[CountrySelected]" 	: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.CountrySelected) : TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description) 	: TableI = TableI + 1
		TableData (TableI,0) = "[DeviceType]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) =  clean(objItem.DeviceType)		: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
							
	'''''''''''''''''''''''''''
	'   Mouse Information     '
	'''''''''''''''''''''''''''
	Comment = "MouseInfo"
	Dim mouse_type
	Dim mouse_port
	
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_PointingDevice",,48)
								
	For Each objItem In ColItems
		mouse_type = objItem.PointingType
		if mouse_type = "1" then mouse_type = "Other" End If
		if mouse_type = "2" then mouse_type = "Unknown" End If
		if mouse_type = "3" then mouse_type = "Mouse" End If
		if mouse_type = "4" then mouse_type = "Track Ball" End If
		if mouse_type = "5" then mouse_type = "Track Point" End If
		if mouse_type = "6" then mouse_type = "Glide Point" End If
		if mouse_type = "7" then mouse_type = "Touch Pad" End If
		if mouse_type = "8" then mouse_type = "Touch Screen" End If
		if mouse_type = "9" then mouse_type = "Mouse - Optical Sensor" End If
		mouse_port = objItem.DeviceInterface
		if mouse_port = "1" then mouse_port = "Other" End If
		if mouse_port = "2" then mouse_port = "Unknown" End If
		if mouse_port = "3" then mouse_port = "Serial" End If
		if mouse_port = "4" then mouse_port = "PS/2" End If
		if mouse_port = "5" then mouse_port = "Infrared" End If
		if mouse_port = "6" then mouse_port = "HP-HIL" End If
		if mouse_port = "7" then mouse_port = "Bus mouse" End If
		if mouse_port = "8" then mouse_port = "ADB (Apple Desktop Bus)" End If
		if mouse_port = "160" then mouse_port = "Bus mouse DB-9" End If
		if mouse_port = "161" then mouse_port = "Bus mouse micro-DIN" End If
		if mouse_port = "162" then mouse_port = "USB" End If


		TableI = 0
		TableData (TableI,0) = "[DeviceID]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID) 		: TableI = TableI + 1
		TableData (TableI,0) = "[Description]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Description) 	: TableI = TableI + 1
		TableData (TableI,0) = "[NumberOfButtons]" 	: TableData (TableI,1) = "integer" 		: TableData (TableI,2) = clean(objItem.NumberOfButtons)	: TableI = TableI + 1
		TableData (TableI,0) = "[mouse_type]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mouse_type 					: TableI = TableI + 1
		TableData (TableI,0) = "[mouse_port]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = mouse_port 					: TableI = TableI + 1
		TableData (TableI,0) = "" 					: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
			
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	'''''''''''''''''''''''''''
	'   Sound Information     '
	'''''''''''''''''''''''''''
	Comment = "SoundCardInfo"
	LongComment = LongComment + Comment
	if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
	Set ColItems = objWMIService.ExecQuery("Select * from Win32_SoundDevice",,48)
		
	For Each objItem In ColItems
	
		TableI = 0
		TableData (TableI,0) = "[DeviceID]"				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.DeviceID)	: TableI = TableI + 1
		TableData (TableI,0) = "[Manufacturer]" 		: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Manufacturer): TableI = TableI + 1
		TableData (TableI,0) = "[Name]" 				: TableData (TableI,1) =  MyTypeMemo  	: TableData (TableI,2) = clean(objItem.Name)        : TableI = TableI + 1
		TableData (TableI,0) = "" 						: TableData (TableI,1) = "" 			: TableData (TableI,2) = ""

		TableWhere (0,0) = "[eComputer]" 			: TableWhere (0,1) =  MyTypeMemo  	: TableWhere (0,2) = ComputerName
		TableWhere (1,0) = "[DeviceID]" 			: TableWhere (1,1) =  MyTypeMemo  	: TableWhere (1,2) = clean(objItem.DeviceID)
		TableWhere (2,0) = "" 						: TableWhere (2,1) = "" 			: TableWhere (2,2) = ""

		XMLDoTableAr Comment, DBTableVersion, TableData, TableWhere, XMLfileObj
		DBDoTableAr DBGetTableName(Comment), DBTableVersion, TableData, TableWhere, DBhistoryUnique 
			
	Next
	DBClearHistory(DBGetTableName(Comment)) , True : mydebug (comment & " done")
	 
	'LogFileWrite(longcomment)
	XMLWrite XMLfileObj,ComputerNameGet()		
	EventLogWrite EVENT_SUCCESS, WScript.ScriptFullName & " Execution Time: " & ToolsTimerGet()  & " seconds."
	' End of Hardware

End Function

Function Deconstruct(strIn)
strOut = ""
For x = 1 To Len(strIn)
	If Asc(Mid(strIn,x,1)) > 128 Then
	strOut = strOut & "&#" & Asc(Mid(strIn,x,1))
	Else
	strOut = strOut & Mid(strIn,x,1)
	End If
Next

Deconstruct = strOut
End Function


Function HostDrives(sHost)
Const LOCAL_DISK = 3
Dim Disks, Disk, aTmp(), i
Set Disks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk where DriveType=" & LOCAL_DISK)
ReDim aTmp(Disks.Count - 1)
i = -1
For Each Disk In Disks
i = i + 1
aTmp(i) = Disk.DeviceID
Next
HostDrives = aTmp
End Function

Function DrivePartition(sHost, sDrive)
Dim Associator, Associators
Set Associators = objWMIService.ExecQuery ("Associators of {Win32_LogicalDisk.DeviceID=""" & sDrive & """} WHERE ResultClass=CIM_DiskPartition")
if DDEEVV = true then On Error Goto 0 Else On Error Resume Next
For Each Associator In Associators
DrivePartition = Associator.Name
If Err.Number <>0 then Err.Clear
Next
End Function

Function IsConnectible(sHost,iPings,iTO)
If sHost = "." Then
IsConnectible = True
Else
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
	Set oShell = CreateObject("WScript.Shell")
	Set oExCmd = oShell.Exec("ping -n " & iPings & " -w " & iTO & " " & sHost)
	Select Case InStr(oExCmd.StdOut.Readall,"TTL=")
	Case 0 IsConnectible = False
	Case Else IsConnectible = True
	End Select
End If
End Function

Function NSlookup(sHost)
' Both IP address and DNS name is allowed
' Function will return the opposite
Dim oRe
Dim bInpIP

Set oRe = New RegExp
oRe.Pattern = "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
bInpIP = False
If oRe.Test(sHost) Then
	bInpIP = True
End If

Dim oshell
Dim oFS
Dim sTemp
Dim STempFile

Set oShell = CreateObject("Wscript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
STempFile = sTemp & "\" & oFS.GetTempName
'Run NSLookup via Command Prompt
'Dump results into a temp text file
	oShell.Run "%ComSpec% /c nslookup.exe " & sHost & " >" & STempFile, 0, True
'Open the temp Text File and Read out the Data

Dim oTF
Dim sLine
Dim aLine
Dim sData

Set oTF = oFS.OpenTextFile(sTempFile)
'Parse the text file
Do While Not oTF.AtEndOfStream
	sLine = Trim(oTF.Readline)
	If LCase(Left(sLine, 5)) = "name:" Then
		sData = Trim(Mid(sLine, 6))
		If Not bInpIP Then
			'Next line will be IP address(es)
			'Line can be prefixed with "Address:" or "Addresses":
			aLine = Split(oTF.Readline, ":")
			sData = Trim(aLine(1))
		End If
		Exit Do
	End If
Loop
'Close it
oTF.Close
'Delete It
oFS.DeleteFile STempFile
If LCase(TypeName(sData)) = LCase("Empty") Then
	NSlookup = ""
Else
	NSlookup = sData
End If
End Function

Function HowMany()
Dim Proc1,Proc2,Proc3
Set Proc1 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set Proc2 = Proc1.ExecQuery("select * from win32_process" )
HowMany=0
For Each Proc3 In Proc2
	If LCase(Proc3.Caption) = "cscript.exe" Then
	HowMany=HowMany + 1
	End If
Next
End Function

Sub entry(form_input, comment,objTextFile,oAdd,oComment)
If form_input <> "" Then
If online = "n" Then
	objTextFile.WriteLine(form_input)
End If
If online = "ie" Or online = "yesxml" Then
	form_total = form_total + form_input + VbCrLf
End If
End If
End Sub



Function getResultFromFileExpression(node)
Dim result,child
For Each child In node.childNodes

	'Check if the tag is reconised
	If (Not(child.nodeName = "file" Or child.nodeName="and" Or child.nodeName="or" Or child.nodeName="xor" Or child.nodeName="not")) Then
		Err.Raise 1, "getResultFromFileExpression", "Unknown tag: " & child.nodeName
	End If

	' If the result is currently empty then create one
	If (IsEmpty(result)) Then
		If (child.nodeName = "file") Then
		result = fileExists(child)
		Else
		result = getResultFromFileExpression(child)
		End If

		If (node.nodeName = "not") Then
		result = Not result
		End If

	'If the result isn't empty and nodeName is incorrect then raise error
	ElseIf (node.nodeName = "not" Or node.nodeName = "test" Or node.nodeName = "file") Then
		Err.Raise 2, "getResultFromFileExpression", "Incorrect nesting within the node: " & node.nodeName

	'and
	ElseIf (node.nodeName = "and") Then
		If (child.nodeName = "file") Then
		result = result And fileExists(child)
		Else
		result = result And getResultFromFileExpression(child)
		End If


	'or
	ElseIf (node.nodeName = "or") Then
		If (child.nodeName = "file") Then
		result = result Or fileExists(child)
		Else
		result = result Or getResultFromFileExpression(child)
		End If

	'xor
	ElseIf (node.nodeName = "xor") Then
		If (child.nodeName = "file") Then
		result = result Xor fileExists(child)
		Else
		result = result Xor getResultFromFileExpression(child)
		End If

	'root node
	ElseIf (node.nodeName = "test") Then
		If (child.nodeName = "file") Then
		'Shouldn't be able to get here
		Err.Raise 2, "getResultFromFileExpression", "Incorrect nesting within the node: " & node.nodeName
		Else
		result = getResultFromFileExpression(child)
		End If

	End If

	'Shortcut
	If (node.nodeName = "and" And result = False) Then
		getResultFromFileExpression = False
		Exit Function
	ElseIf (node.nodeName = "or" And result = True) Then
		getResultFromFileExpression = True
		Exit Function
	End If

Next
getResultFromFileExpression = result
End Function

Function fileExists(aNode)
If (aNode.nodeName <>"file") Then
	Err.Raise 3, "fileExists", "Incorrect node type passed to function: " & node.nodeName
End If

sFilename = aNode.getAttribute("filename")
Set colFiles = objWMIService.ExecQuery("Select Name,Version,Manufacturer,FileSize from CIM_DataFile where Name = '" & sFilename & "'")
If (colFiles.Count=0) Then
		fileExists = False
	Else
		For Each objFile In colFiles

			If (IsNull(aNode.getAttribute("size"))) Then
				'Don't test filesize
			Else
				If (aNode.getAttribute("size") <> objFile.FileSize) Then
					fileExists = False
					Exit Function
				Else
					'filesize matches
				End If
			End If

			If (IsNull(aNode.getAttribute("version"))) Then
				'Don't need to test version
			Else
				If (aNode.getAttribute("version") <> objFile.version) Then
					fileExists = False
					Exit Function
				Else
					'Version matches
				End If
			End If
		Next
		fileExists = True
	End If
End Function

Function urlEncode(sString)
Dim nIndex, aCode, theString
Set theString = CreateObject("ADODB.Stream")
theString.Type = 2 'Binary?
theString.Open
theString.Position = 0

For nIndex = 1 To Len(sString)
	aCode = AscW(Mid(sString,nIndex,1))

	'convert from twos complement
	If aCode < 0 Then
	aCode = 65536 + aCode
	End If

	If ((aCode >= 48 And aCode <= 57) Or (aCode >= 65 And aCode <=90) Or (aCode >= 97 And aCode <= 122)) Then
	'Alphanumerics
	theString.WriteText Chr(aCode)
	ElseIf (aCode = 45 Or aCode = 46 Or aCode = 95 Or aCode = 126) Then
	'Following characters: - / . / _ / ~
	theString.WriteText Chr(aCode)
	ElseIf (aCode < 16) Then
	theString.WriteText "%0" & Hex(aCode)
	ElseIf (aCode < 128) Then
	theString.WriteText "%" & Hex(aCode)
	ElseIf (aCode < 2048) Then
	theString.WriteText "%" & Hex(((aCode) \ 2^6) Or 192)
	theString.WriteText "%" & Hex(((aCode And 63)) Or 128)
	ElseIf (aCode < 65536) Then
	theString.WriteText "%" & Hex(((aCode) \ 2^12) Or 224)
	theString.WriteText "%" & Hex(((aCode And 4032) \ 2^6) Or 128)
	theString.WriteText "%" & Hex(((aCode And 63)) Or 128)
	End If
Next

theString.position = 0
urlEncode = theString.ReadText()

End Function

dim NicbFound

function NicGetDuplex(strComputer,nicname)
	' COMMENT: Based in part on as script by RMAC461 found at 
	' http://www.scriptinganswers.com/archive/articles/NICSettings-SpeedandDuplex.htm

	Dim objReg, strKeyPath, arrSubKeys, subKey
	Dim i
	
	NicGetDuplex = ""

	Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		MsgBox "Failed to query " & strComputer & ". " & Err.Description,vbCritical + vbOKOnly,"Error"
		WScript.Quit
	End If 
	
	strKeyPath = "System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"
	
	objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath , arrSubKeys, nicname

	Dim aKeys
	
	'list of places to look
	aKeys = Array("DuplexMode","SpeedDuplex","RequestedMediaType","Media","Media_Type","MPMODE")
	
	For Each subkey In arrSubKeys
		For i = 0 to UBound (aKeys)
			NicGetDuplex = NICGetInfo ( aKeys(i), strKeyPath, subkey, objReg, nicname)
			
			If NicbFound Then Exit function
		Next
	Next
	'mydebug " NicGetDuplex 2" & NicGetDuplex
End function

function NICGetInfo(strValue,strKeyPath,subkey,objReg,nicname)
	dim strNICName, dwValue
	NICGetInfo = ""
	'mydebug strKeyPath & "\" & subkey & " DriverDesc " & strValue
	objReg.GetStringvalue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey,"DriverDesc", strNICName
	If strNICName <> NICName Then Exit function
	objReg.GetStringvalue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subKey,strValue, dwValue
	If dwValue <> "" Then
		'message =  message & VbCrLf
		NICGetInfo = NICLookupDetail ( strNicName, strValue, dwValue )
		mydebug " NICGetInfo  " & NICGetInfo
		NicbFound = True
	End If
End function

Dim NicLastNICLookupDetailDetails 

function NICLookupDetail (NicName,strKey,Val)
	' What a pain! The duplex information will be right some of the time.  
	' You will probably need to edit it to detect the most common NICs in your domain
	Dim strDuplex
	If strKey = "MPMODE" Then 'AMD reverses ord
		NicLastNICLookupDetailDetails = "AMD" & " " & Val
		Select Case Val
			Case 0	strDuplex = "Auto Detect"
			Case 1  strDuplex = "100Mb Half Duplex"
			Case 2  strDuplex = "100Mb Full Duplex"
			Case 3	strDuplex = "10Mb Half Duplex"
			Case 4  strDuplex = "10Mb Full Duplex"
		End Select 
	ElseIf 	InStr(UCase(NicName), "BROADCOM") > 0 Then 	'broadcom departs from numbering
		NicLastNICLookupDetailDetails = "BROADCOM" & " " & Val
		Select Case Val
			Case 0	strDuplex = "Auto Detect"
			Case 3	strDuplex = "10Mb Half Duplex"
			Case 4  strDuplex = "10Mb Full Duplex"
			Case 5  strDuplex = "100Mb Half Duplex"
			Case 6  strDuplex = "100Mb Full Duplex"
		End Select 
	Else
		NicLastNICLookupDetailDetails = "other NIC" & " " & Val
		Select Case val	'all other NICS?
			Case 0	strDuplex = "Auto Detect"
			Case 1	strDuplex = "10Mb Half Duplex"
			Case 2  strDuplex = "10Mb Full Duplex"
			Case 3  strDuplex = "100Mb Half Duplex"
			Case 4  strDuplex = "100Mb Full Duplex"
			Case 5  strDuplex = "1 Gigabit Full Duplex" ' another guess
		End Select 
	End If 
	
	mydebug "Duplex Registry Value: " & strKey &  " = " &  Val & VbCrLf 
	mydebug "Duplex Setting is probably: " &  strDuplex & VbCrLf 
	NICLookupDetail = strDuplex
End function

function NicLinkSpeedGet(Strcomputer,nicname)
	dim oWMI, oNDIS, oLink
	NicLinkSpeedGet= ""
	Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
	Set oNDIS = oWMI.ExecQuery("Select * from MSNDIS_LinkSpeed where InstanceName = '" & nicname & "'",,48)
		For Each oLink In oNDIS
		NicLinkSpeedGet = (oLink.NDISLinkSpeed  / 10000) &  " Mbps" 
	Next
	
	if NicLinkSpeedGet = "" then  NicLinkSpeedGet = "Link Speed Not Available"
	mydebug "NicLinkSpeedGet  " & NicLinkSpeedGet
end function


'' SIG '' Begin signature block
'' SIG '' MIID6AYJKoZIhvcNAQcCoIID2TCCA9UCAQExDjAMBggq
'' SIG '' hkiG9w0CBQUAMGYGCisGAQQBgjcCAQSgWDBWMDIGCisG
'' SIG '' AQQBgjcCAR4wJAIBAQQQTvApFpkntU2P5azhDxfrqwIB
'' SIG '' AAIBAAIBAAIBAAIBADAgMAwGCCqGSIb3DQIFBQAEEM66
'' SIG '' C3dvU84Y+bsM1ceDLOugggISMIICDjCCAXegAwIBAgIQ
'' SIG '' fduYp37PJolB2l4qUoy9tjANBgkqhkiG9w0BAQQFADAV
'' SIG '' MRMwEQYDVQQDEwplLW52ZW50b3J5MB4XDTEwMTIzMTIz
'' SIG '' MDAwMFoXDTE2MTIzMTIzMDAwMFowFTETMBEGA1UEAxMK
'' SIG '' ZS1udmVudG9yeTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
'' SIG '' gYkCgYEAxoqL8otb0bZl/B6QNeNKa7wgv9FzkgeuH0/K
'' SIG '' Mqta3uf+k/JJF0eRdm/e+R17t2Fy0nn4kkfK/0339ZKA
'' SIG '' j+LrC6N0Z2XzotG2Tf5CR2XYHwGWtXvL1edczqrPEwnJ
'' SIG '' Bep8Fki6p0/CSSFueWSjRmMr3nP5+PNnMWarU/OyVdep
'' SIG '' yDMCAwEAAaNfMF0wEwYDVR0lBAwwCgYIKwYBBQUHAwMw
'' SIG '' RgYDVR0BBD8wPYAQlJeutLm/XtOFAEGETQ1/HKEXMBUx
'' SIG '' EzARBgNVBAMTCmUtbnZlbnRvcnmCEH3bmKd+zyaJQdpe
'' SIG '' KlKMvbYwDQYJKoZIhvcNAQEEBQADgYEAKFw68m9BqK1a
'' SIG '' mJUm2YxwCsT3mWy4nilgTWlC+wj64jouYVSY1Ozhm7L8
'' SIG '' ALBzVvvFCeHMHmvpN4pZdqzAf9CnTcNWPkYBq5Hep2aM
'' SIG '' by6t/JiG9lPhC327WWW5IQV3T+FtK2G1qW9UMGi83PMV
'' SIG '' FhUJeBp5hhxXhWORlcBZg5aiVpgxggFAMIIBPAIBATAp
'' SIG '' MBUxEzARBgNVBAMTCmUtbnZlbnRvcnkCEH3bmKd+zyaJ
'' SIG '' QdpeKlKMvbYwDAYIKoZIhvcNAgUFAKBsMBAGCisGAQQB
'' SIG '' gjcCAQwxAjAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3
'' SIG '' AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEEAYI3AgEV
'' SIG '' MB8GCSqGSIb3DQEJBDESBBCyZKWdzinp7DQ8Iqy2mnqp
'' SIG '' MA0GCSqGSIb3DQEBAQUABIGAdEsqDi7hUPnFlrAJpS/n
'' SIG '' u3EG5XmVEvjwlZT1V5sutRKt4fttPBRTdzF6gs1audZF
'' SIG '' o+Z7LleN8EBCYEOzF+wMH1NDJ2JOVHj+Ikpv47QkHOp8
'' SIG '' raq+J9do51t336kH2ALdqz23MdARPkp1htUbGWyAXxom
'' SIG '' Ej0AGMLZzt1Ebv9R82s=
'' SIG '' End signature block
